<?php 
define('IN_WONDERSHARE', true);
header("Content-type:text/html;charset=utf-8");
require('../includes/init.php');
require('./classes/control/control_faq_online_help.php');
class Faq_Online_Help
{
	var $faq_online_help_c;
	var $webType;//网站类型
	/**
	* @ 构造函数,实例化CommentControl
	* @ __construct
	*/
	
	public function __construct()
	{
	
		$this->faq_online_help_c = new FaqOnlineHelpControl();
		$this->webType = empty($_REQUEST['web_type'])?1:(int)trim($_REQUEST['web_type']);
	}

	/**
	* 函数index,返回默认列表
	* @param  NULL
	* @return  string
	*/
	function index()
	{
	
		$url_info = $new_info = $category_info = array();
		//分页处理
		$page = !empty($_REQUEST['page'])?(int)$_REQUEST['page']: 1;
		$page_size = 20;
		$help_title = !empty($_POST['help_title'])?trim($_POST['help_title']):urldecode(trim($_GET['help_title']));
		if($_POST['search'] || !empty($_REQUEST['url_page']) )//搜索以及分页
		{
			$search_array = array
			(
			'is_video' => trim($_REQUEST['help_video']),
			'status' => trim($_REQUEST['help_status']),
			'id' => (int)(trim($_REQUEST['help_id'])),
			'p_cbsid' => (int)(trim($_REQUEST['p_cbsid'])),
			'title' => $help_title
			);
			$url_info = $this->faq_online_help_c->get_url_info($page,'list_s',$page_size,$this->webType,$search_array);
			$help_info = $this->faq_online_help_c->get_help_info('list_s',$url_info['page_info']['start'],$page_size,$this->webType,$search_array);
		}else
		{
			$url_info = $this->faq_online_help_c->get_url_info($page,'list',$page_size,$this->webType);
			$help_info = $this->faq_online_help_c->get_help_info('list',$url_info['page_info']['start'],$page_size,$this->webType);
		}
		$GLOBALS['smarty']->assign('web_type',   $this->webType);
		$GLOBALS['smarty']->assign('help_id',   trim($_REQUEST['help_id']));
		$GLOBALS['smarty']->assign('help_title',  $help_title);
		$GLOBALS['smarty']->assign('help_status',  trim($_REQUEST['help_status']));
		$GLOBALS['smarty']->assign('p_cbsid',  trim($_REQUEST['p_cbsid']));
		$GLOBALS['smarty']->assign('help_video',   trim($_REQUEST['help_video']));
		$GLOBALS['smarty']->assign('page_url',   $url_info['page_url']);
		$GLOBALS['smarty']->assign('help_info',$help_info );
		$GLOBALS['smarty']->assign('total',   $url_info['page_info']['total']);
		$GLOBALS['smarty']->display('faq_online_help_index.htm'); 
	}

	/**
	* 函数index,返回默认列表
	* @param  NULL
	* @return  string
	*/
	
	public function edit()
	{	
		if($_REQUEST['act'] == 'edit' && !empty($_REQUEST['help_id']))
		{ 
			$help_info = $this->faq_online_help_c->get_help_id_info((int)$_REQUEST['help_id']);
			$GLOBALS['smarty']->assign('web_type',   $this->webType);
			$GLOBALS['smarty']->assign('chr_13',     chr(13));
			$GLOBALS['smarty']->assign('help_info',$help_info);
			$GLOBALS['smarty']->display('faq_online_help_info.htm'); 	
		}
	}
}
$action    = $_REQUEST['action']; 
$faq_online_help   = new Faq_Online_Help;
if(method_exists($faq_online_help, $action)) 
{
	$faq_online_help->$action();
}else{
	$faq_online_help->index();
}

?>
